package com.lagou.job.common;

import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;

/**
 * 通用返回类
 * @author yzh
 */
@Data
@Builder
public class Result implements Serializable {

    /**
     * 结果编码
     */
    private String code;

    /**
     * 结果信息
     */
    private String msg;

    /**
     * 数据
     */
    private Object data;

    public static Result success() {
        return new Result(Constant.SUCCESS, Constant.SUCCESS_COMMON_MSG, new ArrayList<>());
    };

    public static Result error() {
        return new Result(Constant.ERROR, Constant.ERROR_COMMON_MSG, new ArrayList<>());
    };

    public static Result success(Object data) {
        return new Result(Constant.SUCCESS, Constant.SUCCESS_QUERY_MSG, data);
    };

    public static Result error(Object data) {
        return new Result(Constant.SUCCESS, Constant.ERROR_QUERY_MSG, data);
    };

    public static Result success(Object data, String msg) {
        return new Result(Constant.SUCCESS, msg, data);
    };

    public static Result error(Object data, String msg) {
        return new Result(Constant.SUCCESS, msg, data);
    };
}
